package com.zzc.qqchat.repository;

import com.zzc.qqchat.domain.BuildGroupList;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;

public interface BuildGroupListRep extends JpaRepository<BuildGroupList,Integer> {

    @Query(value = "select * from Build_Group_List where rece_Id=?1",nativeQuery = true)
    ArrayList<BuildGroupList> findByReceId(int receId);

    @Query(value = "select * from Build_Group_List where rece_Id=?1 and group_Id=?2",nativeQuery = true)
    ArrayList<BuildGroupList> findByReceIdAndGroupId(int receId,int groupId);

    @Modifying
    @Transactional
    @Query(value = "delete from Build_Group_List where rece_Id=?1 and group_Id=?2",nativeQuery = true)
    int deleteByReceAndSenderId(int receiverId,int groupId);


}
